import RenderEngine from "./render_engine";
import EventCenter from "./event_center";
import Event from "./event";
import Stage from "./stage";
import ViewContainer from "./view_container";
import View from "./view";
import Bitmap from "./bitmap";
import Shape from "./shape";
import Movie from "./movie";
import Text from "./text";
import Button from "./button";
import Motion from "./motion";
import ScrollView from "./scroll_view";
import TableView from "./table_view";
import SpinView from "./spin_view";
import ViewFactory from "./view_factory";

export default class Axe {
  constructor(m, g, y?) {
    ViewFactory.addClass("stage", Stage),
      ViewFactory.addClass("container", ViewContainer),
      ViewFactory.addClass("view", View),
      ViewFactory.addClass("bitmap", Bitmap),
      ViewFactory.addClass("shape", Shape),
      ViewFactory.addClass("movie", Movie),
      ViewFactory.addClass("text", Text),
      ViewFactory.addClass("button", Button),
      ViewFactory.addClass("motion", Motion),
      ViewFactory.addClass("scroll", ScrollView),
      ViewFactory.addClass("table", TableView),
      ViewFactory.addClass("spin", SpinView),
      console.log('ViewFactory', ViewFactory.ViewClasses),
      (this.stageCtrl = new m()),
      typeof g == "string"
        ? (this.stageCtrl.initWithURL(g),
          console.log('this.stageCtrl', this.stageCtrl),
          EventCenter.addListener(this.stageCtrl, this, Event.PREPARED, function () {
            console.log('event_center', this.stageCtrl)
            this._renderEngine = new RenderEngine(this.stageCtrl.view());
          }))
        : (this.stageCtrl.init(),
          (this._renderEngine = new RenderEngine(this.stageCtrl.view())));
  }
  stageCtrl = null;
  _renderEngine = null;
  renderEngine() {
    return this._renderEngine;
  }
  initRenderEngine() {}
}
